#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

# 
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base
WORKDIR /app
#EXPOSE 80
#EXPOSE 443
#EXPOSE 5001
EXPOSE 5041

# 
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src
COPY ["miniMana/miniMana.csproj", "miniMana/"]
RUN dotnet restore "miniMana/miniMana.csproj"
COPY . .
WORKDIR "/src/miniMana"
RUN dotnet build "miniMana.csproj" -c Release -o /app/build

# 
FROM build AS publish
RUN dotnet publish "miniMana.csproj" -c Release -o /app/publish /p:UseAppHost=false

#Define signature password
#WORKDIR /app/publish
#ENV certPassword 123456
#RUN openssl genrsa -des3 -passout pass:${certPassword} -out server.key 2048
#RUN openssl rsa -passin pass:${certPassword} -in server.key -out server.key
#RUN openssl req -sha256 -new -key server.key -out server.csr -subj '/CN=localhost'
#RUN openssl x509 -req -sha256 -days 365 -in server.csr -signkey server.key -out server.crt
#RUN openssl pkcs12 -export -out server.pfx -inkey server.key -in server.crt -certfile server.crt -passout pass:${certPassword}
#
#copy kaodd.top.pem /etc/ssl/certs/
#copy kaodd.top.key  /etc/ssl/private/

# 
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "miniMana.dll"]